<template>
  <div class="detailpage">
    <!-- v-if="type === '预算局工作清单'" -->
    <!-- <template v-if="title === '资产清查表'">
      <zcczTable></zcczTable>
    </template> -->

    <template>
      <!-- <tome-home /> -->
      <ysqd
        :responseUrl="responseUrl"
        :enterpriseName="enterpriseName"
        :enterpriseId="enterpriseId"
        :formGuid="formGuid"
        :formName="formName"
        :instId="instId"
        :tableId="tableId"
        :fileType="fileType"
        :sId="sid"
        :taskId="taskId"
        :nodeId="nodeId"
        :defId="defId"
        :showSPBtns="getIsShowBottomBtns"
        :assigneeNames="assigneeNames"
        :title="title"
      />
    </template>
    <!-- <template v-else>
      <template v-if="loginLoading">
        <a-spin :spinning="loginLoading" tip="正在登录...">
          <div style="width:100vw;height:100vh;" />
        </a-spin>
      </template>
      <template v-else>
        <div>
          <div class="page-unknow">
            该表格属于复杂表格，功能暂未开发，请去pc端办理
          </div>
        </div>
      </template>
    </template> -->
  </div>
</template>

<script type="text/ecmascript-6">
/*eslint-disable*/
import freeLogin from "@/utils/freelogin.js";
import {initNavTitle,appName} from '@/utils/utils.ts'
import { toLogin } from "@/utils/login.js";
import ddGoBackFilter from "@/views/home/homemixin";
import {
        taskCheck
   } from '@/api/itemLayout';
// const TomeHome = () => import("@/views/components/TaoComponents/index.vue");
export default {

  data () {
    return {
      title: "",
      responseUrl:'',
      enterpriseName:'',
      sid: "",
      instId: "",
      taskId: "",
      tableId: "",
      nodeId: "",
      type: "",
      formGuid: "",
      formName: "",
      assigneeNames: "",
      enterpriseId: "",
      showSPBtns: "0",
      fileType: "",
      defId: "",
      checkType:false
    };
  },
  created() {
    const backItemLayout = localStorage.getItem('backItemLayout')
    if (backItemLayout === '2') {
      localStorage.setItem('backItemLayout','1')
      this.$router.go(-1)
    }
  },
  mixins:[freeLogin, ddGoBackFilter],
  methods: {
    async pageTextInit() {
      await toLogin(this);
      // await this.pageInit();
    },

    getQueryVariable(name) {
      let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
      let r = decodeURIComponent(location.href.substr(1)).match(reg);
      let context = "";
      if (r != null) context = r[2];
      reg = null;
      r = null;
      return context == null || context == "" || context == "undefined"
        ? ""
        : context;
    },
    async taskCheck(data){
      return await taskCheck(data)
    },
    async pageInit(){
      const { getQueryVariable } = this;
      const getUrlDatas = [
        'title',
        'enterpriseName',
        'sid',
        'enterpriseId',
        'formGuid',
        'assigneeNames',
        'instId',
        'taskId',
        'nodeId',
        'defId',
        'responseUrl',
        'showSPBtns',
        'fileType',
        'formName',
        'tableId',
        ]

      const isqr = getQueryVariable('qrCode')
      getUrlDatas.forEach(item => {
        const data = getQueryVariable(item)
        this[item] = data
      })
      isqr ? this.title = '资产购置表' : '';
      const navTitle = this.formName ?? this.appName;
      initNavTitle(navTitle)
      if (this.showSPBtns === "1") {
        const taskCheck = await this.taskCheck({taskId:this.taskId})
        if (taskCheck.code === 200 && taskCheck.success) {
          if (taskCheck.data === '1' || 'ok') {
             this.checkType = true
          }else{
              await this.$message.warning('该事项已被办理')
              this.showSPBtns = "0"
          }
        }
      }
      localStorage.setItem('sid',this.sid)
    }
  },
  computed:{
    getIsShowBottomBtns(){
      if (this.showSPBtns === "1" && this.checkType) {
        return "1"
      } 
      return "0"
    }
  },
  components: {
    // TomeHome,
    ysqd: () => import("./DetailPage/ysqd/index.vue")
  }
};
</script>

<style lang="less" scoped>
.detailpage {
  width: 100%;
  height: 100vh;
  background-color: #f7f7f7;
  .page-unknow {
    width: 100%;
    height: 80%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
</style>
